package com.truesai.entities.market;

import java.math.BigDecimal;
import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.truesai.entities.customer.Customer;
import com.truesai.entities.employee.Employee;
/**
 * 产品销售总表<br/>
 * 需求分析<br/>
 * <strong>唯一性:</strong>(员工id,客户id,销售日期)=流水号
 * @author XuLian
 *
 */
@Entity
@NamedQueries(
{
        @NamedQuery(name = Market.ALL, query = "Select m from Market m"),
        @NamedQuery(name = Market.BY_SERIALNUMBER, query = "Select m from Market m where m.serialNumber = :erialNumber"),
        @NamedQuery(name = Market.BY_ID, query = "Select m from Market m where m.id = :id") })
@Table(name = "Markets")
public class Market {
	public static final String ALL = "Market.all";

    public static final String BY_SERIALNUMBER = "Market.bySerialNumber";

    public static final String BY_ID = "Market.byId";
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**流水号*/
    @Column(nullable = false)
    private String serialNumber;
    
    /**销售日期*/
    @Column(nullable = false)
    private Date sellDate;
    
    /**销售员工*/
    @ManyToOne
    private Employee employee;
    
    /**员工销售提成*/
    @Column
    private Float percentToSellerAvg;
    
    /**客户*/
    @ManyToOne
    private Customer customer;
    
    /**总销售额*/
    @Column(scale=2)
    private BigDecimal totalPrice;
    
    /**实际客户支付总销售额*/
    @Column(scale=2)
    private BigDecimal factTotalPrice;
    
    /**总利润*/
    @Column(scale=2)
    private BigDecimal totalProfit;
    
    /**实际总利润*/
    @Column(scale=2)
    private BigDecimal factTotalProfit;
    
    public Market() { }
    
    public Market(String serialNumber, Date sellDate, Employee employee, Float percentToSeller, Customer customer,
    		BigDecimal totalPrice, BigDecimal factTotalPrice, BigDecimal totalProfit, BigDecimal factTotalProfit) {
    	this.serialNumber = serialNumber;
    	this.sellDate = sellDate;
    	this.employee = employee;
    	this.percentToSellerAvg = percentToSeller;
    	this.customer = customer;
    	this.totalPrice = totalPrice;
    	this.factTotalPrice = factTotalPrice;
    	this.totalProfit = totalProfit;
    	this.factTotalProfit = factTotalProfit;
    }

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public Date getSellDate() {
		return sellDate;
	}

	public void setSellDate(Date sellDate) {
		this.sellDate = sellDate;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Float getPercentToSellerAvg() {
		return percentToSellerAvg;
	}

	public void setPercentToSellerAvg(Float percentToSeller) {
		this.percentToSellerAvg = percentToSeller;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public BigDecimal getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}

	public BigDecimal getFactTotalPrice() {
		return factTotalPrice;
	}

	public void setFactTotalPrice(BigDecimal factTotalPrice) {
		this.factTotalPrice = factTotalPrice;
	}

	public BigDecimal getTotalProfit() {
		return totalProfit;
	}

	public void setTotalProfit(BigDecimal totalProfit) {
		this.totalProfit = totalProfit;
	}

	public BigDecimal getFactTotalProfit() {
		return factTotalProfit;
	}

	public void setFactTotalProfit(BigDecimal factTotalProfit) {
		this.factTotalProfit = factTotalProfit;
	}
    
}
